#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int sum(int n,int f){
    int a=3;
    int ans=0;
    while(n>0){
        int t=(int)pow(f,a);
        ans+=(n/t);
        n%=t;
        a--;
    }
    return ans;
}
bool judge(int n){
    if(sum(n,10)==sum(n,12) && sum(n,10)==sum(n,16) && sum(n,12)==sum(n,16)){
        return true;
    }
    return false;
}
int main(void){
    for(int i=1000;i<=9999;i++){
        if(judge(i)){
            printf("%d\n",i);
        }
    }
    return 0;
}
